package md.lanjing.com.module_deal_center.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import md.lanjing.com.module_deal_center.api.DealApiService;
import md.lanjing.com.module_deal_center.bean.DealVoucherRequest;
import md.lanjing.com.module_deal_center.bean.DealVoucherResponce;
import com.lxh.baselibray.constant.Constant;
import retrofit2.Call;
import retrofit2.Response;

public class DealVoucherContact {
    public static class DealVoucherPresent extends BasePresent<IDealVoucherView> {
        public void confirmDealVoucher(final Context context, String transferId, String transfer_pic, String payment, String dealPwd){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            DealVoucherRequest request=new DealVoucherRequest(userId,transferId,transfer_pic,payment, Md5Utils.stringToMD5(dealPwd));
            service.dealVoucher(request).enqueue(new NetCallBack<DealVoucherResponce>() {
                @Override
                public void onSuccess(Call<DealVoucherResponce> call, Response<DealVoucherResponce> response) {
                    if (getView()!=null){
                        getView().getDealVoucherData( response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IDealVoucherView extends IBaseView {
        void getDealVoucherData(Response<DealVoucherResponce> response);
    }
}
